/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: app2022 - T22
 * <p>Powered by webrx On 2022-02-07 16:11:34
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T22 {
    volatile static boolean f = false;

    public static void main(String[] args) {
        new Thread(() -> {
            String tn = Thread.currentThread().getName();
            System.out.println(tn + "线程启动运行中....");
            while (!f) {
                try {
                    TimeUnit.SECONDS.sleep(1);
                    System.out.printf("%s...%n", tn);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            System.out.println(tn + "结束");
        }, "worker").start();

        try {
            TimeUnit.SECONDS.sleep(5);
        } catch (Exception e) {
            e.printStackTrace();
        }
        f = true;
    }
}
